let uu = document.querySelector('.uu')
let foot = document.querySelector('.footer')
let span = document.querySelector('span')
fetch('http://chst.vip:1234/api/getinlanddiscount')
.then(body=>body.json())
.then(res=>{
    console.log(res)
    render(res.result,uu)
})
function render(data,el){
    console.log(data,el)
    let domStr=''
    data.forEach(item=>{
        console.log(item.productImg)
        // let li = document.createElement('li')
        // let regExp= /(?<=imgurl=)[^'"]*/
        // let result = item.productImg.match(regExp)
        // console.log(result)
        // result = result[0]
        // console.log(result)
        domStr += `<li ><img src="../images/红枣.jpg" alt="" productid=${item.productId}><h3>${item.productName}</h3>
        </li>
        `
        el.innerHTML = domStr
        // el.appendChild(li)
    })
}
uu.onclick=function(e){
    console.log(e.target)
    if(e.target.localName == 'img'){
        let _this = e.target
        console.log(_this)
        let id = _this.getAttribute('productid')
        console.log(id);
        location.href = "./../html/guoneixiang.html?productid="+id
        id = Number(id)
        console.log(id)
    }
}



span.onclick = function(){
    location.href = "./../index.html"
}
foot.onclick=function(){
    location.href = "./../index.html"
}